package org.msfj.common.util;

import java.util.UUID;

/**
 * @Description: 主键生成工具
 * @User: like
 * @Date: 2017/2/24
 */
public class IdWorker {
    /**
     * 主机和进程的机器码
     */
    private static Sequence worker = new Sequence();

    public static String getId(){
        try {
            return String.valueOf(worker.nextId());
        }catch (Exception e){
            return null;
        }

    }

    /**
     * <p>
     * 获取去掉"-" UUID
     * </p>
     */
    public static synchronized String get32UUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    public static void main(String[] args) {
        System.out.println(IdWorker.getId());
    }
}
